package main_package;

import java.io.BufferedReader;
import java.io.FileReader;
import java.util.ArrayList;

import part_1.Random_monkey_alg;

public class Main 
{

	public static void main(String[] args)
	{
		//initializing variables
		String str;
		FileReader fr = null;
		BufferedReader br = null;
		Random_monkey_alg rma = new Random_monkey_alg();
		String hamlet_file = "";

		try 
		{
			fr = new FileReader("hamlet.txt");
			br = new BufferedReader(fr);

			// as long as the file has more lines to read
			while ((str = br.readLine()) != null)
			{
				hamlet_file = hamlet_file+str;
			}

			//building alphabet
			ArrayList<Character> alphabet=buildAlphabet();

			fr.close();
			br.close();


			//printing the date of beginning of the algorithm
			System.out.println(new java.util.Date());

			//running random algorithm for monkey problem
			rma.run_alg(hamlet_file, alphabet);


			//printing date of finish
			System.out.println(new java.util.Date());

		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
	}

	//function that builds alphabet from the hamlet text
	private static ArrayList<Character> buildAlphabet()
	{
		ArrayList<Character> alphabet=new ArrayList<Character>();

		String chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz :.',";

		//adding each character in the alphabet and some more punctuaion marks
		for(int i=0;i < chars.length();i++)
		{
			alphabet.add(chars.charAt(i));
		}

		return alphabet;
	}
}
